package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TournamentProgress;
import com.ruoyi.system.service.ITournamentProgressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 赛事项目/进度Controller
 *
 * @author ruoyi
 * @date 2022-04-26
 */
@RestController
@RequestMapping("/system/progress")
public class TournamentProgressController extends BaseController
{
    @Autowired
    private ITournamentProgressService tournamentProgressService;

    /**
     * 查询赛事项目/进度列表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:list')")
    @GetMapping("/list")
    public TableDataInfo list(TournamentProgress tournamentProgress)
    {
        startPage();
        List<TournamentProgress> list = tournamentProgressService.selectTournamentProgressList(tournamentProgress);
        return getDataTable(list);
    }

    /**
     * 获取项目信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:progress:query')")
    @PostMapping("/queryView")
    public AjaxResult queryView(@RequestBody TournamentProgress tournamentProgress)
    {
        return AjaxResult.success(tournamentProgressService.selectTournamentProgressQueryViewList(tournamentProgress));
    }

    /**
     * 导出赛事项目/进度列表
     */
    @PreAuthorize("@ss.hasPermi('system:progress:export')")
    @Log(title = "赛事项目/进度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TournamentProgress tournamentProgress)
    {
        List<TournamentProgress> list = tournamentProgressService.selectTournamentProgressList(tournamentProgress);
        ExcelUtil<TournamentProgress> util = new ExcelUtil<TournamentProgress>(TournamentProgress.class);
        util.exportExcel(response, list, "赛事项目/进度数据");
    }

    /**
     * 获取赛事项目/进度详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:progress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tournamentProgressService.selectTournamentProgressById(id));
    }

    /**
     * 新增赛事项目/进度
     */
    @PreAuthorize("@ss.hasPermi('system:progress:add')")
    @Log(title = "赛事项目/进度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TournamentProgress tournamentProgress)
    {
        return toAjax(tournamentProgressService.insertTournamentProgress(tournamentProgress));
    }

    /**
     * 修改赛事项目/进度
     */
    @PreAuthorize("@ss.hasPermi('system:progress:edit')")
    @Log(title = "赛事项目/进度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TournamentProgress tournamentProgress)
    {
        return toAjax(tournamentProgressService.updateTournamentProgress(tournamentProgress));
    }

    /**
     * 删除赛事项目/进度
     */
    @PreAuthorize("@ss.hasPermi('system:progress:remove')")
    @Log(title = "赛事项目/进度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tournamentProgressService.deleteTournamentProgressByIds(ids));
    }
}
